var sApiKey = 'ABQIAAAACPZarB0vXhPLiBjfhYUbuRQVzOX5TNUSOXEAxJ-shN8dJYSi1RQHB8See0y4nHu4KUpXIKRBjRwrlA';


/*
 * set the var sApiKey depending on the url.
 * redirect to the right domain if not selected.
 */
function setGmapsAPI() {
 	var url = location.href;	
	if (url.substr(7,15) == 'www.crowdup.org') {
		redirect("www.crowdup.com");
	}
	else if (url.substr(7,15) == 'www.crowdup.com'){
		sApiKey = "ABQIAAAAH6fqUVTBmv25WVYY4f6RphQEiH595vlkByYdQDDhBQTg_cQKQxTaSBwTJBs_ulwHFpftHhrUnWp6uQ";
	}
}


/*
 * redirect to the given domain.
 * 
 */
function redirect(server) {
	var url = location.href;
	if (url.indexOf('?') > -1) {
		var qStringArray = urlUsed.split('?');
		if (qStringArray[1].length > 0) 			
			urlParams = '?' + qStringArray[1];
	}	    	
	location.href='http://' + server + urlParams;
}


/*
 * Write the header for inserting the google maps javascript
 * 
 */
function drawHeader() {
	
	var content;
	content = '<script src="http://maps.google.com/maps?file=api&v=2&key=' + sApiKey + '" type="text/javascript"></script>';
	
	document.write(content);
	
}

setGmapsAPI();
drawHeader();
